const express = require("express");
const dotenv = require("dotenv");
const cors = require("cors");

dotenv.config();

const app = express();
const port = process.env.PORT || 3000;
const tableRoutes = require("./routes/table");

app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

app.use("/table", tableRoutes);

app.use((err, req, res, next) => {
  res.status(500).json({ error: "Internal Server Error", message: err });
});

app.listen(port, () => {
  console.log(`Server is running on port ${port}`);
});
